/**
 * Created by dukes on 2016/3/2.
 */
class GuildPanel extends eui.Component {
    private frameItem:FrameItem;
    public constructor() {
        super();
        this.name = "guildPanel";
        this.skinName = "skins.scene.GuildPanelSkin";
        // this.frameItem = new FrameItem(this, this.update);
        // this.addEventListener(egret.Event.ADDED_TO_STAGE,this.onAdded, this );
        // this.addEventListener(egret.Event.REMOVED_FROM_STAGE, this.onRemoved, this);
    }

    // public update(){
    //     var info = GuildMgr.getInstance().guildInfo;
    //     if( !info) return;
    //     var gap;
    //     var hehe = 0;
    //     var needRefresh = false;
    //     if( info.factoryUpgradeFinishTime > Model.SYSTIME){
    //         gap =  info.factoryUpgradeFinishTime - Model.SYSTIME;
    //         this.timer_bg_factory.visible = true;
    //         this.timer_factory.visible = true;
    //         this.timer_factory.text = GetTimeStr(gap,2,true);
    //         this.btn_fact_upgrade.source = RES.getRes("img_fuck_guild_42");
    //     }else{
    //         if( info.factoryUpgradeFinishTime != 283968000000){
    //             needRefresh = true;
    //         }
    //         this.timer_bg_factory.visible = false;
    //         this.timer_factory.visible = false;
    //         this.lv_factory.text = info.factoryLevel + "";
    //         this.btn_fact_upgrade.source = RES.getRes("img_fuck_guild_44");
    //         hehe++;
    //     }
    //     if( info.shopUpgradeFinishTime > Model.SYSTIME){
    //         gap =  info.shopUpgradeFinishTime - Model.SYSTIME;
    //         this.timer_bg_shop.visible = true;
    //         this.timer_shop.visible = true;
    //         this.timer_shop.text = GetTimeStr(gap,2,true);
    //         this.btn_shop_upgrade.source = RES.getRes("img_fuck_guild_42");
    //     }else{
    //         this.timer_bg_shop.visible = false;
    //         this.timer_shop.visible = false;
    //         this.lv_shop.text = info.shopLevel + "";
    //         this.btn_shop_upgrade.source = RES.getRes("img_fuck_guild_44");
    //         hehe++;
    //         if( info.shopUpgradeFinishTime != 283968000000){
    //             needRefresh = true;
    //         }
    //     }
    //     if( info.upgradeFinishTime > Model.SYSTIME){
    //         gap =  info.upgradeFinishTime - Model.SYSTIME;
    //         this.timer_bg_lobby.visible = true;
    //         this.timer_lobby.visible = true;
    //         this.timer_lobby.text = GetTimeStr(gap,2,true);
    //         this.btn_lobby_upgrade.source = RES.getRes("img_fuck_guild_42");
    //     }else{
    //         this.timer_bg_lobby.visible = false;
    //         this.timer_lobby.visible = false;
    //         this.lv_lobby.text = info.level + "";
    //         this.btn_lobby_upgrade.source = RES.getRes("img_fuck_guild_44");
    //         hehe++;
    //         if( info.upgradeFinishTime != 283968000000){
    //             needRefresh = true;
    //         }
    //     }
    //     if( info.warehouseUpgradeFinishTime > Model.SYSTIME){
    //         gap =  info.warehouseUpgradeFinishTime - Model.SYSTIME;
    //         this.timer_bg_warehouse.visible = true;
    //         this.timer_warehouse.visible = true;
    //         this.timer_warehouse.text = GetTimeStr(gap,2,true);
    //         this.btn_warehouse_upgrade.source = RES.getRes("img_fuck_guild_42");
    //     }else{
    //         this.timer_bg_warehouse.visible = false;
    //         this.timer_warehouse.visible = false;
    //         this.lv_warehouse.text = info.warehouseLevel + "";
    //         this.btn_warehouse_upgrade.source = RES.getRes("img_fuck_guild_44");
    //         hehe++;
    //         if( info.warehouseUpgradeFinishTime != 283968000000){
    //             needRefresh = true;
    //         }
    //     }
    //     if( hehe == 4){
    //         FrameMgr.getInstance().delController(this.name);
    //     }
    //     if( needRefresh && Model.SYSTIME - this.lastRefreshTime > 60000){
    //         window["__refreshFamily"]();
    //         this.lastRefreshTime = Model.SYSTIME;
    //     }
    // }
    // private lastRefreshTime = 0;
    // public onUpgradeBack(){
    //     if( !FrameMgr.getInstance().isUnderControl(this.name) ){
    //         FrameMgr.getInstance().addControll(this.frameItem);
    //     }
    // }

    // public onLobby(evt:egret.TouchEvent){
    //     SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GUILD_LOBBY);
    //     RedPointMgr.getInstance().update(RedPointMgr.GUILD_LOBBY_ICON,false);
    // }

    // public onMedal(evt:egret.TouchEvent){
    //     SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GUILD_MEDAL);
    // }

    // public onQuit(evt:egret.TouchEvent){
    //     if( GuildMgr.getInstance().guildInfo.shaikhId == Model.me.id ){
    //        RemindPanel.getInstance().showContent("都是一起出来混的兄弟，说散伙就散伙，这样真的好吗？",this, this.dismiss);
    //     }else{
    //         RemindPanel.getInstance().showContent("离开家族后您将失去家族等级所带来的工厂位，商店位以及族徽加成。你当真要离开日夜一起奋斗的兄弟姐妹吗？",this, this.quit);
    //     }
    // }

    // public dismiss(){
    //     window["__dismissGuild"]();
    // }

    // public quit(){
    //     window["__quitGuild"]();
    // }
    // public updateDisplay(){
    //     var info = GuildMgr.getInstance().guildInfo;
    //     this.updateBtnDisplay();
    //     this.btn_fact_upgrade.visible = this.btn_lobby_upgrade.visible = this.btn_shop_upgrade.visible = this.btn_warehouse_upgrade.visible = GuildMgr.getInstance().guildInfo.shaikhId == Model.me.id;
    //     this.lv_lobby.text = info.level + "";
    //     this.lv_medal.text = GuildMgr.getInstance().guildLogo.level + "";
    //     this.lv_shop.text = info.shopLevel + "";
    //     this.lv_factory.text = info.factoryLevel + "";
    //     this.lv_warehouse.text = info.warehouseLevel + "";
    //     this.img_quit.source = RES.getRes(GuildMgr.getInstance().guildInfo.shaikhId == Model.me.id ? "img_dismiss_guild" : "img_quit_guild")
    // }
    // public onBtnLobby(evt:egret.TouchEvent){
    //     if(GuildMgr.getInstance().guildInfo.upgradeFinishTime < Model.SYSTIME){
    //         GuildUpgradePanel.getInstance().show(Model.GUILD_LOBBY);
    //     }else{
    //         BuyTimePanel.getInstance().show(GuildMgr.getInstance().guildInfo.upgradeFinishTime,this, this.okLobby);
    //     }
    // }
    // private okLobby(){
    //     window["__speedupFamily"](Model.GUILD_LOBBY);
    // }

    // public onShop(evt:egret.TouchEvent){
    //     SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GUILD_SHOP);
    // }
    // public onShopBtn(evt:egret.TouchEvent){
    //     if(GuildMgr.getInstance().guildInfo.shopUpgradeFinishTime < Model.SYSTIME){
    //         GuildUpgradePanel.getInstance().show(Model.GUILD_SHOP);
    //     }else{
    //         BuyTimePanel.getInstance().show(GuildMgr.getInstance().guildInfo.shopUpgradeFinishTime,this, this.okShop);
    //     }
    // }
    // private okShop(){
    //     window["__speedupFamily"](Model.GUILD_SHOP);
    // }
    // public onFactory(evt:egret.TouchEvent){
    //     SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GUILD_FACTORY);
    // }
    // public onFactoryBtn(evt:egret.TouchEvent){
    //     if(GuildMgr.getInstance().guildInfo.factoryUpgradeFinishTime < Model.SYSTIME){
    //         GuildUpgradePanel.getInstance().show(Model.GUILD_FACTORY);
    //     }else{
    //         BuyTimePanel.getInstance().show(GuildMgr.getInstance().guildInfo.factoryUpgradeFinishTime,this, this.okFact);
    //     }
    // }
    // private okFact(){
    //     window["__speedupFamily"](Model.GUILD_FACTORY);
    // }
    // public onWarehouse(evt:egret.TouchEvent){
    //     SceneMgr.getInstance().switchScene(SceneMgr.SCENE_GUILD_WAREHOUSE);
    // }
    // public onWarehouseBtn(evt:egret.TouchEvent){
    //     if(GuildMgr.getInstance().guildInfo.warehouseUpgradeFinishTime < Model.SYSTIME){
    //         GuildUpgradePanel.getInstance().show(Model.GUILD_WAREHOUSE);
    //     }else{
    //         BuyTimePanel.getInstance().show(GuildMgr.getInstance().guildInfo.warehouseUpgradeFinishTime,this, this.okWarehoust);
    //     }
    // }
    // private okWarehoust(){
    //     window["__speedupFamily"](Model.GUILD_WAREHOUSE);
    // }

    // public updateBtnDisplay(){
    //     var info = GuildMgr.getInstance().guildInfo;
    //     this.btn_fact_upgrade.source = info.factoryUpgradeFinishTime > Model.SYSTIME ? "img_fuck_guild_42":"img_fuck_guild_44";
    //     this.btn_lobby_upgrade.source = info.upgradeFinishTime > Model.SYSTIME ? "img_fuck_guild_42":"img_fuck_guild_44";
    //     this.btn_shop_upgrade.source = info.shopUpgradeFinishTime > Model.SYSTIME ? "img_fuck_guild_42":"img_fuck_guild_44";
    //     this.btn_warehouse_upgrade.source = info.warehouseUpgradeFinishTime > Model.SYSTIME ? "img_fuck_guild_42":"img_fuck_guild_44";
    // }
    // private onAdded(evt:egret.Event){
    //     FrameMgr.getInstance().addControll(this.frameItem);
    //     this.img_shop.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onShop, this);
    //     this.btn_enter_shop.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onShop, this);
    //     this.img_lobby.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onLobby, this);
    //     this.img_quit.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onQuit, this);
    //     this.img_medal.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onMedal, this);
    //     this.btn_enter_lobby.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onLobby, this);
    //     this.btn_enter_medal.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onMedal, this);
    //     this.img_fact.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onFactory, this);
    //     this.btn_enter_fact.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onFactory, this);
    //     this.img_warehouse.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onWarehouse, this);
    //     this.btn_enter_warehouse.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onWarehouse, this);
    //     this.btn_lobby_upgrade.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnLobby, this);
    //     this.btn_shop_upgrade.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onShopBtn, this);
    //     this.btn_fact_upgrade.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onFactoryBtn, this);
    //     this.btn_warehouse_upgrade.addEventListener(egret.TouchEvent.TOUCH_TAP, this.onWarehouseBtn, this);
    // }
    // private onRemoved(evt:egret.Event){
    //     FrameMgr.getInstance().delController(this.name);
    //     this.img_shop.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onShop, this);
    //     this.btn_enter_shop.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onShopBtn, this);
    //     this.img_lobby.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onLobby, this);
    //     this.img_quit.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onQuit, this);
    //     this.img_medal.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onMedal, this);
    //     this.btn_enter_lobby.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnLobby, this);
    //     this.btn_enter_medal.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onMedal, this);
    //     this.img_fact.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onFactory, this);
    //     this.btn_enter_fact.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onFactoryBtn, this);
    //     this.img_warehouse.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onWarehouse, this);
    //     this.btn_enter_warehouse.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onWarehouseBtn, this);
    //     this.btn_lobby_upgrade.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onBtnLobby, this);
    //     this.btn_shop_upgrade.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onShopBtn, this);
    //     this.btn_fact_upgrade.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onFactoryBtn, this);
    //     this.btn_warehouse_upgrade.removeEventListener(egret.TouchEvent.TOUCH_TAP, this.onWarehouseBtn, this);
    // }
    // public img_lobby:eui.Image;
    // private btn_enter_lobby:eui.Image;
    // private lv_lobby:eui.BitmapLabel;
    // public img_medal:eui.Image;
    // public img_quit:eui.Image;
    // private btn_enter_medal:eui.Image;
    // private lv_medal:eui.BitmapLabel;
    // public img_shop:eui.Image;
    // private btn_enter_shop:eui.Image;
    // private lv_shop:eui.BitmapLabel;
    // private lv_factory:eui.BitmapLabel;
    // private lv_warehouse:eui.BitmapLabel;
    // public img_fact:eui.Image;
    // private btn_enter_fact:eui.Image;
    // public img_warehouse:eui.Image;
    // private btn_enter_warehouse:eui.Image;
    // public btn_lobby_upgrade:eui.Image;
    // private btn_shop_upgrade:eui.Image;
    // public btn_fact_upgrade:eui.Image;
    // private btn_warehouse_upgrade:eui.Image;
    // public timer_bg_lobby:eui.Image;
    // private timer_lobby:eui.BitmapLabel;
    // public timer_bg_shop:eui.Image;
    // private timer_shop:eui.BitmapLabel;
    // public timer_bg_factory:eui.Image;
    // private timer_factory:eui.BitmapLabel;
    // public timer_bg_warehouse:eui.Image;
    // public hint_guild:eui.Image;
    // private timer_warehouse:eui.BitmapLabel;
    // public partAdded(name:string, instance:any) {
    //     super.partAdded(name, instance);
    //     if (name == "img_lobby") {
    //         this.img_lobby = instance;
    //     } else if (name == "btn_enter_lobby") {
    //         this.btn_enter_lobby = instance;
    //     }else if (name == "img_medal") {
    //         this.img_medal = instance;
    //     }else if (name == "btn_enter_medal") {
    //         this.btn_enter_medal = instance;
    //     }else if (name == "lv_lobby") {
    //         this.lv_lobby = instance;
    //     }else if (name == "lv_medal") {
    //         this.lv_medal = instance;
    //     }else if (name == "img_quit") {
    //         this.img_quit = instance;
    //     }else if (name == "img_shop") {
    //         this.img_shop = instance;
    //     }else if (name == "btn_enter_shop") {
    //         this.btn_enter_shop = instance;
    //     }else if (name == "lv_shop") {
    //         this.lv_shop = instance;
    //     }else if (name == "lv_factory") {
    //         this.lv_factory = instance;
    //     }else if (name == "lv_warehouse") {
    //         this.lv_warehouse = instance;
    //     }else if (name == "img_fact") {
    //         this.img_fact = instance;
    //     }else if (name == "btn_enter_fact") {
    //         this.btn_enter_fact = instance;
    //     }else if (name == "img_warehouse") {
    //         this.img_warehouse = instance;
    //     }else if (name == "btn_enter_warehouse") {
    //         this.btn_enter_warehouse = instance;
    //     }else if (name == "btn_lobby_upgrade") {
    //         this.btn_lobby_upgrade = instance;
    //     }else if (name == "btn_shop_upgrade") {
    //         this.btn_shop_upgrade = instance;
    //     }else if (name == "btn_fact_upgrade") {
    //         this.btn_fact_upgrade = instance;
    //     }else if (name == "btn_warehouse_upgrade") {
    //         this.btn_warehouse_upgrade = instance;
    //     }else if (name == "timer_bg_lobby") {
    //         this.timer_bg_lobby = instance;
    //     }else if (name == "timer_lobby") {
    //         this.timer_lobby = instance;
    //     }else if (name == "timer_bg_shop") {
    //         this.timer_bg_shop = instance;
    //     }else if (name == "timer_shop") {
    //         this.timer_shop = instance;
    //     }else if (name == "timer_bg_factory") {
    //         this.timer_bg_factory = instance;
    //     }else if (name == "timer_factory") {
    //         this.timer_factory = instance;
    //     }else if (name == "timer_bg_warehouse") {
    //         this.timer_bg_warehouse = instance;
    //     }else if (name == "timer_warehouse") {
    //         this.timer_warehouse = instance;
    //     }else if (name == "hint_guild") {
    //         this.hint_guild = instance;
    //         RedPointMgr.getInstance().registerPoint(RedPointMgr.GUILD_LOBBY_ICON,instance);
    //     }
    // }
    private static _instance:GuildPanel;
    public static getInstance():GuildPanel{
        if( GuildPanel._instance == null)
            GuildPanel._instance = new GuildPanel();
        return GuildPanel._instance;
    }
}